/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "Supplies")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Supplies.findAll", query = "SELECT s FROM Supplies s ORDER BY s.supName ASC"),
    @NamedQuery(name = "Supplies.findBySupID", query = "SELECT s FROM Supplies s WHERE s.supID = :supID"),
    @NamedQuery(name = "Supplies.findBySupName", query = "SELECT s FROM Supplies s WHERE s.supName = :supName"),
    @NamedQuery(name = "Supplies.findBySupSpoken", query = "SELECT s FROM Supplies s WHERE s.supSpoken = :supSpoken"),
    @NamedQuery(name = "Supplies.findBySupOnHand", query = "SELECT s FROM Supplies s WHERE s.supOnHand = :supOnHand"),
    @NamedQuery(name = "Supplies.findBySupWH", query = "SELECT s FROM Supplies s WHERE s.supWH = :supWH"),
    @NamedQuery(name = "Supplies.findBySupPrice", query = "SELECT s FROM Supplies s WHERE s.supPrice = :supPrice"),
    @NamedQuery(name = "Supplies.findBySupQtyPer", query = "SELECT s FROM Supplies s WHERE s.supQtyPer = :supQtyPer"),
    @NamedQuery(name = "Supplies.findBySupUnits", query = "SELECT s FROM Supplies s WHERE s.supUnits = :supUnits"),
    @NamedQuery(name = "Supplies.findBySupNumber", query = "SELECT s FROM Supplies s WHERE s.supNumber = :supNumber"),
    @NamedQuery(name = "Supplies.findBySupOnOrder", query = "SELECT s FROM Supplies s WHERE s.supOnOrder = :supOnOrder"),
    @NamedQuery(name = "Supplies.findByMinimumQty", query = "SELECT s FROM Supplies s WHERE s.minimumQty = :minimumQty"),
    @NamedQuery(name = "Supplies.findBySupNotes", query = "SELECT s FROM Supplies s WHERE s.supNotes = :supNotes"),
    @NamedQuery(name = "Supplies.findByLeadTime", query = "SELECT s FROM Supplies s WHERE s.leadTime = :leadTime"),
    @NamedQuery(name = "Supplies.findResaleable", query = "SELECT s FROM Supplies s WHERE s.supResalable = 'true' ORDER BY s.supName ASC"),
    @NamedQuery(name = "Supplies.findAllSAF", query = "SELECT s FROM Supplies s WHERE s.supWH = '130' ORDER BY s.supName ASC")})
public class Supplies implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "SupID")
    private Integer supID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 100)
    @Column(name = "SupName")
    private String supName;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SupSpoken")
    private float supSpoken;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SupOnHand")
    private float supOnHand;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SupWH")
    private int supWH;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SupPrice")
    private float supPrice;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SupQtyPer")
    private float supQtyPer;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 50)
    @Column(name = "SupUnits")
    private String supUnits;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 50)
    @Column(name = "SupNumber")
    private String supNumber;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SupOnOrder")
    private float supOnOrder;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MinimumQty")
    private float minimumQty;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "SupNotes")
    private String supNotes;
    @Basic(optional = false)
    @NotNull
    @Column(name = "LeadTime")
    private int leadTime;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Resaleable")
    private boolean supResalable;
    @Basic(optional = false)
    @NotNull
    @Column(name = "taxExempt")
    private boolean taxExempt;
    @Basic(optional = false)
    @NotNull
    @Column(name = "version")
    @Version
    private int version;
    @Column(name = "ReSalePrice")
    private float supReSalePrice;
    @Column(name = "WholeSalePrice")
    private float supWholeSalePrice;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Attrition")
    private float attrition;
    @OneToMany(mappedBy = "invPSOSupplyID")
    private Collection<InvPSOLines> invPSOLinesCollection;
    @OneToMany(mappedBy = "invSaleSupplyID")
    private Collection<InvSalesLines> invSalesLinesCollection;
    @OneToOne
    @JoinTable(
        name="JTSuppliesToStockCode",
        joinColumns={ @JoinColumn(name="SupID", referencedColumnName="SupID", unique=true)},
        inverseJoinColumns={ @JoinColumn(name="StockID", referencedColumnName="StockID", unique=true)}
    )
    private StockCode stockCode;
    @OneToMany(mappedBy = "supID")
    private Collection<WaterSalts> waterSaltCollection;

    public Supplies() {
    }

    public Supplies(Integer supID) {
        this.supID = supID;
    }

    public Supplies(Integer supID, String supName, float supSpoken, float supOnHand, int supWH, float supPrice, float supQtyPer, String supUnits, String supNumber, float supOnOrder, float minimumQty, String supNotes, int leadTime, boolean supResalable, float supReSalePrice, float supWholeSalePrice, boolean taxExempt) {
        this.supID = supID;
        this.supName = supName;
        this.supSpoken = supSpoken;
        this.supOnHand = supOnHand;
        this.supWH = supWH;
        this.supPrice = supPrice;
        this.supQtyPer = supQtyPer;
        this.supUnits = supUnits;
        this.supNumber = supNumber;
        this.supOnOrder = supOnOrder;
        this.minimumQty = minimumQty;
        this.supNotes = supNotes;
        this.leadTime = leadTime;
        this.supResalable = supResalable;
        this.supReSalePrice = supReSalePrice;
        this.supWholeSalePrice = supWholeSalePrice;
        this.taxExempt = taxExempt;
    }

    public Integer getSupID() {
        return supID;
    }

    public void setSupID(Integer supID) {
        this.supID = supID;
    }

    public String getSupName() {
        return supName;
    }

    public void setSupName(String supName) {
        this.supName = supName;
    }

    public float getSupSpoken() {
        return supSpoken;
    }

    public void setSupSpoken(float supSpoken) {
        this.supSpoken = supSpoken;
    }

    public float getSupOnHand() {
        return supOnHand;
    }

    public void setSupOnHand(float supOnHand) {
        this.supOnHand = supOnHand;
    }

    public int getSupWH() {
        return supWH;
    }

    public void setSupWH(int supWH) {
        this.supWH = supWH;
    }

    public float getSupPrice() {
        return supPrice;
    }

    public void setSupPrice(float supPrice) {
        this.supPrice = supPrice;
    }

    public float getSupQtyPer() {
        return supQtyPer;
    }

    public void setSupQtyPer(float supQtyPer) {
        this.supQtyPer = supQtyPer;
    }

    public String getSupUnits() {
        return supUnits;
    }

    public void setSupUnits(String supUnits) {
        this.supUnits = supUnits;
    }

    public String getSupNumber() {
        return supNumber;
    }

    public void setSupNumber(String supNumber) {
        this.supNumber = supNumber;
    }

    public float getSupOnOrder() {
        return supOnOrder;
    }

    public void setSupOnOrder(float supOnOrder) {
        this.supOnOrder = supOnOrder;
    }

    public float getMinimumQty() {
        return minimumQty;
    }

    public void setMinimumQty(float minimumQty) {
        this.minimumQty = minimumQty;
    }

    public String getSupNotes() {
        return supNotes;
    }

    public void setSupNotes(String supNotes) {
        this.supNotes = supNotes;
    }

    public int getLeadTime() {
        return leadTime;
    }

    public void setLeadTime(int leadTime) {
        this.leadTime = leadTime;
    }
    
    public boolean getSupResalable(){
        return supResalable;
    }
    
    public void setSupResalable(boolean supResalable){
        this.supResalable = supResalable;
    }
    
    public float getSupReSalePrice(){
        return supReSalePrice;
    }
    
    public void setSupReSalePrice(float supReSalePrice){
        this.supReSalePrice = supReSalePrice;
    }
    
    public float getSupWholeSalePrice(){
        return supWholeSalePrice;
    }
    
    public void setSupWholeSalePrice(float supWholeSalePrice){
        this.supWholeSalePrice = supWholeSalePrice;
    }

    public boolean isTaxExempt() {
        return taxExempt;
    }

    public void setTaxExempt(boolean taxExempt) {
        this.taxExempt = taxExempt;
    }

    public StockCode getStockCode() {
        return stockCode;
    }

    public void setStockCode(StockCode stockCode) {
        this.stockCode = stockCode;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    public float getAttrition() {
        return attrition;
    }

    public void setAttrition(float attrition) {
        this.attrition = attrition;
    }

    @XmlTransient
    public Collection<InvPSOLines> getInvPSOLinesCollection() {
        return invPSOLinesCollection;
    }

    public void setInvPSOLinesCollection(Collection<InvPSOLines> invPSOLinesCollection) {
        this.invPSOLinesCollection = invPSOLinesCollection;
    }

    @XmlTransient
    public Collection<InvSalesLines> getInvSalesLinesCollection() {
        return invSalesLinesCollection;
    }

    public void setInvSalesLinesCollection(Collection<InvSalesLines> invSalesLinesCollection) {
        this.invSalesLinesCollection = invSalesLinesCollection;
    }

    @XmlTransient
    public Collection<WaterSalts> getWaterSaltCollection() {
        return waterSaltCollection;
    }

    public void setWaterSaltCollection(Collection<WaterSalts> waterSaltCollection) {
        this.waterSaltCollection = waterSaltCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (supID != null ? supID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Supplies)) {
            return false;
        }
        Supplies other = (Supplies) object;
        if ((this.supID == null && other.supID != null) || (this.supID != null && !this.supID.equals(other.supID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.Supplies[ supID=" + supID + " ]";
    }
    
    public String getDisplay(){
        return Integer.toString(this.supID) + " - " + this.supName;
    }
    
}
